#pragma once

#include <list>
#include "Thread.h"
#include "Mutex.h"
#include "Condition.h"


class ThreadWaiter
{
public:
    ThreadWaiter(int max = 10) : m_size(0), m_max(max)
    {
    }
    ~ThreadWaiter(void)
    {
    }

    void Append(Thread* pThread);
    void Remove(Thread* pThread);
    void Wait();
    void IncreaseThread(int size = 1);
    void DecreaseThread(int size = 1);

private:
    std::list<pthread_t> m_threads;
    int m_size;
    int m_max;
    Mutex m_mutex;
    Condition m_cond;
};

